package com.haircut.api.user;

import com.haircut.sys.service.user.IUserService;
import com.haircut.sys.vo.user.ApiUserVo;
import com.haircut.sys.vo.user.UpdatePwdVo;
import com.haircut.sys.vo.user.UserOnlyVo;
import com.modular.result.RspMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户信息")
@RestController
@RequestMapping("/api")
public class ApiUserController {
    @Autowired
    private IUserService userService;

    /**
     * 获得用户信息
     */
    @ApiOperation("获得用户信息")
    @GetMapping("getUserDetail")
    public RspMessage<ApiUserVo> getUserDetail(){
        return RspMessage.success(userService.getUserDetail());
    }
    /**
     * 修改用户
     * @param userVo
     * @return
     */
    @ApiOperation(value = "修改当前登录人用户")
    @PostMapping("modifyProfile")
    public RspMessage<Void> modifyProfile(@Validated @RequestBody UserOnlyVo userVo){
        userService.modifyProfile(userVo);
        return RspMessage.success();
    }

    /**
     * 修改密码
     * @param userVo
     * @return
     */
    @ApiOperation(value = "修改当前登录人用户")
    @PostMapping("updatePwd")
    public RspMessage<Void> modifyProfile(@Validated @RequestBody UpdatePwdVo userVo){
        userService.updatePwd(userVo);
        return RspMessage.success();
    }
}
